package com.fastshopping.order.controller;

import com.fastshopping.order.pojo.Account;
import com.fastshopping.order.service.AccountService;
import com.wink.entity.Result;
import com.wink.entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @GetMapping
    public Result<List<Account>> findAll(){

        List<Account> list = accountService.findAll();

        return new Result(true, StatusCode.OK,"成功",list);
    }

    /*
     * @Author zhangdan
     * @Description //TODO 根据id查询账户
     * @Date 20:01 2020/6/4
     * @Param [id]
     * @return com.wink.entity.Result
     **/
    @GetMapping("/{id}")
    public Result findById(@PathVariable int id){

        Account account = accountService.findById(id);

        return new Result(true, StatusCode.OK,"成功",account);
    }


    /*
     * @Author zhangdan
     * @Description //TODO 根据id查询账户详情明细
     * @Date 18:35 2020/6/5
     * @Param [id]
     * @return com.wink.entity.Result
     **/
    @GetMapping("/detail/{id}")
    public Result findDetailById(@PathVariable int id){

        List<Map> mapList = accountService.findDetailById(id);

        return new Result(true, StatusCode.OK,"成功",mapList);
    }
}
